let xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
    if(xhr.readyState === 4){
        if(xhr.status > 200 && xhr.status < 300 || xhr.status === 304){
            window.alert(JSON.stringify(xhr.responseText))
        }else {
            window.alert(xhr.status + '-'+xhr.responseText)
        }
    }
}
xhr.open('get','https://www.baidu.com',false);
xhr.setRequestHeader('my-name','zw');
xhr.send(null);